<template>
  <div class="commentAction" v-if="isShow">
    <div class="leftTime">{{ formatDate(commit.create_time) }}</div>
    <div class="rightPannel">
      <div :class="['commit']">
        <el-icon>
          <ChatDotSquare />
        </el-icon>
        <span class="message commit-label" @click="handleUpdate(commit.id)">回复</span>
      </div>
      <div :class="['commitD']" @click="() => emits('like', commit.id)">
        <img v-if="commit.is_like == 2" src="@/static/like.png" alt="" />
        <img v-if="commit.is_like == 1" src="@/static/unlike.png" alt="" />

        <span class="pointNumer comment-label">{{ commit.like }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { userEditorStore } from "@/stores/editor.js";
const userEditor = userEditorStore();

const props = defineProps({
  isShow: {
    type: Boolean,
    default: false,
  },
  commit: {
    type: Object,
  },
  current: {
    type: Number,
  },
});

const emits = defineEmits(['like'])

const handleUpdate = (pid) => {
  //初始化设置不同的参数信息
  userEditor.handleUpdate({ key: "maskTitle", value: "回 复" });
  userEditor.handleUpdate({ key: "current", value: props.current });
  userEditor.handleUpdate({ key: "pid", value: pid });
  userEditor.updateEditor(true);
};
</script>

<style lang="scss" scoped>
.commentAction {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0px;

  .leftTime {
    font-family: PingFang SC;
    font-size: 14px;
    font-weight: 400;
    line-height: 19.6px;
    text-align: left;
    color: #999;
    text-underline-position: from-font;
    text-decoration-skip-ink: none;
  }

  .rightPannel {
    display: flex;
    align-items: center;
    gap: 20px;

    .commitD,
    .commit {
      display: flex;
      align-items: center;
      gap: 10px;
      cursor: pointer;

      img {
        width: 1rem;
        height: 1rem;
      }

      .commit-label,
      .comment-label {
        color: #333;
        font-family: PingFang SC;
        font-size: 14px;
        font-weight: 400;
        line-height: 19.6px;
        text-align: left;
        text-underline-position: from-font;
        text-decoration-skip-ink: none;
      }
    }
  }
}
</style>
